<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>My Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="This is my first blog.">
<meta property="og:type" content="website">
<meta property="og:title" content="My Blog">
<meta property="og:url" content="http://yoursite.com/page/11/index.html">
<meta property="og:site_name" content="My Blog">
<meta property="og:description" content="This is my first blog.">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Alanisia">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="My Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.ico">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">My Blog</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">我的博客 -- 记录编程过程中所遇到的问题与总结</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-vim-ycm" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/vim-ycm/" class="article-date">
  <time datetime="2020-03-20T12:12:14.000Z" itemprop="datePublished">2020-03-20</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/vim-ycm/">vim补全插件YouCompleteMe的安装</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>YouCompleteMe是一个VIM代码补全的插件。</p>
<h2 id="Manjaro-ArchLinux"><a href="#Manjaro-ArchLinux" class="headerlink" title="Manjaro/ArchLinux"></a>Manjaro/ArchLinux</h2><p>直接执行以下命令即可自动完成安装。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ sudo pacman -S vim-youcompleteme-git</span><br></pre></td></tr></table></figure>

<h2 id="Termux"><a href="#Termux" class="headerlink" title="Termux"></a>Termux</h2><ol>
<li><p>安装插件管理器(Vundle/VimPlug)</p>
</li>
<li><p>安装clang,vim-python,vim-git</p>
</li>
<li><p>将以下代码写入到~/.vimrc</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">set rtp+&#x3D;~&#x2F;.vim&#x2F;bundle&#x2F;vundle&#x2F;</span><br><span class="line">call vundle#rc() </span><br><span class="line"></span><br><span class="line">&quot; Install YouCompleteMe</span><br><span class="line">Bundle &#39;Valloric&#x2F;YouCompleteMe&#39;</span><br></pre></td></tr></table></figure>

<ol start="4">
<li><p>打开VIM，键入:PlugInstall(VimPlug下命令）并执行</p>
</li>
<li><p>选择youcompleteme插件，安装</p>
</li>
<li><p>安装成功后进入目录~/.vim/plugged/YouCompleteMe，运行以下命令:</p>
</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ./install.py --all --clang-complier</span><br></pre></td></tr></table></figure>

<p>此后YCM将自动进行编译安装。</p>
<h4 id="安装过程中所产生的问题"><a href="#安装过程中所产生的问题" class="headerlink" title="安装过程中所产生的问题"></a>安装过程中所产生的问题</h4><p>进入VIM之后报错:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">The ycmd server SHUT DOWN (restart with ...low the instructions in the documentation.</span><br></pre></td></tr></table></figure>

<p>原因：找不到libdl.so.2</p>
<p>解决办法：Termux不支持glibc库，而libdl.so.2属于glibc库，所以无法安装。可以使用coc.nvim插件来替代。</p>
<h2 id="Ubuntu"><a href="#Ubuntu" class="headerlink" title="Ubuntu"></a>Ubuntu</h2><p>直接安装即可。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ sudo apt-get install vim-yocompleteme</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/vim-ycm/" data-id="ckpb8zvl7003cdsvlcgiof6o5" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vim/" rel="tag">vim</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-mergesort" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/mergesort/" class="article-date">
  <time datetime="2020-03-20T12:11:25.000Z" itemprop="datePublished">2020-03-20</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/mergesort/">归并排序</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>这里记录自己实现的一个归并排序算法。<br>使用typescript语言实现。</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * mergesort demo</span></span><br><span class="line"><span class="comment"> * @author alanisia</span></span><br><span class="line"><span class="comment"> * @version 2.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">'use strict'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * merge</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; left</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; right</span></span><br><span class="line"><span class="comment"> * @return &#123;number[]&#125; </span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">merge</span>(<span class="params">left:<span class="built_in">number</span>[],right:<span class="built_in">number</span>[]</span>):<span class="title">number</span>[]</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> mergeArr:<span class="built_in">number</span>[] = <span class="keyword">new</span> <span class="built_in">Array</span>();</span><br><span class="line">    <span class="keyword">let</span> i = <span class="number">0</span>,j = <span class="number">0</span>,k = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">let</span> l = left.length;</span><br><span class="line">    <span class="keyword">let</span> r = right.length;</span><br><span class="line">    <span class="keyword">while</span> (i &lt; l &amp;&amp; j &lt; r) &#123;</span><br><span class="line">        <span class="keyword">if</span> (left[i] &gt; right[j]) &#123;</span><br><span class="line">            mergeArr[k++] = right[j++];</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            mergeArr[k++] = left[i++];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">while</span> (i &lt; l) &#123;</span><br><span class="line">        mergeArr[k++] = left[i++];</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">while</span> (j &lt; r) &#123;</span><br><span class="line">        mergeArr[k++] = right[j++];</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> mergeArr;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * merge sort</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; arr</span></span><br><span class="line"><span class="comment"> * @return &#123;number[]&#125;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">mergesort</span>(<span class="params">arr:<span class="built_in">number</span>[]</span>):<span class="title">number</span>[] </span>&#123;</span><br><span class="line">    <span class="keyword">let</span> mid:<span class="built_in">number</span> = <span class="built_in">Math</span>.floor(arr.length / <span class="number">2</span>);</span><br><span class="line">    <span class="keyword">let</span> left:<span class="built_in">number</span>[] = arr.slice(<span class="number">0</span>,mid);</span><br><span class="line">    <span class="keyword">let</span> right:<span class="built_in">number</span>[] = arr.slice(mid);</span><br><span class="line">    <span class="keyword">if</span> (arr.length === <span class="number">1</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> merge(left,right);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> merge(mergesort(left),mergesort(right));</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * main function of sorting</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; arr</span></span><br><span class="line"><span class="comment"> * @return &#123;void&#125;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">msort</span>(<span class="params">arr:<span class="built_in">number</span>[]</span>):<span class="title">void</span></span>&#123;</span><br><span class="line">    <span class="keyword">let</span> marr = mergesort(arr);</span><br><span class="line">    <span class="built_in">console</span>.log(marr);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// test arrays</span></span><br><span class="line"><span class="keyword">let</span> array1 = [<span class="number">67</span>,<span class="number">3</span>,<span class="number">19</span>,<span class="number">30</span>,<span class="number">48</span>,<span class="number">72</span>,<span class="number">52</span>,<span class="number">49</span>,<span class="number">3</span>,<span class="number">59</span>,<span class="number">80</span>];</span><br><span class="line"><span class="keyword">let</span> array2 = [<span class="number">73</span>,<span class="number">29</span>,<span class="number">100</span>,<span class="number">58</span>,<span class="number">2</span>,<span class="number">38</span>,<span class="number">-2</span>,<span class="number">48</span>,<span class="number">69</span>,<span class="number">29</span>,<span class="number">50</span>,<span class="number">29</span>];</span><br><span class="line"></span><br><span class="line">msort(array1);</span><br><span class="line">msort(array2);</span><br></pre></td></tr></table></figure>

<p>运行结果:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[3, 3, 19, 30, 48, 49, 52, 59, 67, 72, 80]</span><br><span class="line">[-2, 2, 29, 29, 29, 38, 48, 50, 58, 69, 73, 100]</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/mergesort/" data-id="ckpb8zvkb001qdsvl0p8bestf" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/sorting/" rel="tag">sorting</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-quicksort" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/quicksort/" class="article-date">
  <time datetime="2020-03-19T14:58:58.000Z" itemprop="datePublished">2020-03-19</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/quicksort/">快速排序</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>本文记录自己实现的一个快速排序算法。<br>使用typescript。</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Quicksort demo</span></span><br><span class="line"><span class="comment"> * @author alanisia</span></span><br><span class="line"><span class="comment"> * @version 1.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">'use strict'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> global_mid:<span class="built_in">number</span> = <span class="number">-1</span>; <span class="comment">// global </span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Partition</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; a</span></span><br><span class="line"><span class="comment"> * @return &#123;number[]&#125;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">part</span>(<span class="params">a:<span class="built_in">number</span>[],low:<span class="built_in">number</span>,mid:<span class="built_in">number</span>,high:<span class="built_in">number</span></span>):<span class="title">number</span>[] </span>&#123;</span><br><span class="line">    <span class="keyword">let</span> arr = a;</span><br><span class="line">    <span class="keyword">let</span> temp:<span class="built_in">number</span> = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span>(low &lt; mid &amp;&amp; high &gt; mid) &#123;</span><br><span class="line">        <span class="keyword">if</span>(arr[low] &gt; arr[mid]) &#123;</span><br><span class="line">            temp = arr[low];</span><br><span class="line">            <span class="keyword">for</span>(<span class="keyword">let</span> i = low + <span class="number">1</span>;i &lt;= mid;i++) &#123;</span><br><span class="line">                arr[i - <span class="number">1</span>] = arr[i];</span><br><span class="line">            &#125;</span><br><span class="line">            arr[mid--] = temp;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            low++;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (arr[high] &lt; arr[mid]) &#123;</span><br><span class="line">            temp = arr[high];</span><br><span class="line">            <span class="keyword">for</span> (<span class="keyword">let</span> i = high - <span class="number">1</span>;i &gt;= mid;i--) &#123;</span><br><span class="line">                arr[i + <span class="number">1</span>] = arr[i];</span><br><span class="line">            &#125; </span><br><span class="line">            arr[mid++] = temp;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            high--;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    global_mid = mid;</span><br><span class="line">    <span class="keyword">return</span> arr;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Quick sort</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; arr</span></span><br><span class="line"><span class="comment"> * @param &#123;number&#125; low</span></span><br><span class="line"><span class="comment"> * @param &#123;number&#125; high</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">quicksort</span>(<span class="params">arr:<span class="built_in">number</span>[],low:<span class="built_in">number</span>,high:<span class="built_in">number</span></span>):<span class="title">void</span> </span>&#123;</span><br><span class="line">    <span class="keyword">let</span> mid:<span class="built_in">number</span> = <span class="built_in">Math</span>.floor((low + high) / <span class="number">2</span>);</span><br><span class="line">    <span class="keyword">let</span> newArr:<span class="built_in">number</span>[] = part(arr,low,mid,high);</span><br><span class="line">    <span class="keyword">if</span> (mid &lt;= low) &#123;</span><br><span class="line">        <span class="keyword">if</span> (newArr[low] &gt; newArr[high]) &#123;</span><br><span class="line">            <span class="keyword">let</span> temp = newArr[low];</span><br><span class="line">            newArr[low] = newArr[high];</span><br><span class="line">            newArr[high] = temp;</span><br><span class="line">        &#125; </span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        quicksort(newArr,low,global_mid - <span class="number">1</span>);</span><br><span class="line">        quicksort(newArr,global_mid + <span class="number">1</span>,high);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Main function of quicksort</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">qsort</span>(<span class="params">array:<span class="built_in">number</span>[]</span>):<span class="title">void</span> </span>&#123;</span><br><span class="line">    quicksort(array,<span class="number">0</span>,array.length - <span class="number">1</span>);</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">'The result of sorting:'</span>);</span><br><span class="line">    printArray(array);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Print array</span></span><br><span class="line"><span class="comment"> * @param &#123;number[]&#125; array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">printArray</span>(<span class="params">array:<span class="built_in">number</span>[]</span>):<span class="title">void</span> </span>&#123;</span><br><span class="line">    <span class="keyword">let</span> str:<span class="built_in">string</span> = <span class="string">''</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>;i &lt; array.length;i++) &#123;</span><br><span class="line">        str += <span class="string">`<span class="subst">$&#123;array[i]&#125;</span> `</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">console</span>.log(str);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// Test arrays</span></span><br><span class="line"><span class="keyword">let</span> array1:<span class="built_in">number</span>[] = [<span class="number">12</span>,<span class="number">6</span>,<span class="number">57</span>,<span class="number">12</span>,<span class="number">8</span>,<span class="number">44</span>,<span class="number">12</span>,<span class="number">78</span>,<span class="number">4</span>,<span class="number">1</span>,<span class="number">8</span>];</span><br><span class="line"><span class="keyword">let</span> array2:<span class="built_in">number</span>[] = [<span class="number">90</span>,<span class="number">23</span>,<span class="number">43</span>,<span class="number">55</span>,<span class="number">12</span>,<span class="number">62</span>,<span class="number">3</span>,<span class="number">64</span>,<span class="number">90</span>];</span><br><span class="line"><span class="keyword">let</span> array3:<span class="built_in">number</span>[] = [<span class="number">15</span>,<span class="number">47</span>,<span class="number">89</span>,<span class="number">1</span>,<span class="number">57</span>,<span class="number">32</span>,<span class="number">43</span>,<span class="number">90</span>,<span class="number">72</span>,<span class="number">34</span>,<span class="number">11</span>,<span class="number">1</span>];</span><br><span class="line"></span><br><span class="line">qsort(array1);</span><br><span class="line">qsort(array2);</span><br><span class="line">qsort(array3);</span><br></pre></td></tr></table></figure>

<p>程序运行结果如下:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">The result of sorting:</span><br><span class="line">1 4 6 8 8 12 12 12 44 57 78 </span><br><span class="line">The result of sorting:</span><br><span class="line">3 12 23 43 55 62 64 90 90 </span><br><span class="line">The result of sorting:</span><br><span class="line">1 1 11 15 32 34 43 47 57 72 89 90</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/quicksort/" data-id="ckpb8zvkg001zdsvlcqae8bsw" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/sorting/" rel="tag">sorting</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-vim-config" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/vim-config/" class="article-date">
  <time datetime="2020-03-15T15:27:27.000Z" itemprop="datePublished">2020-03-15</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/vim-config/">vim配置</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>不定期更新。</p>
<h4 id="vim相关配置写在-etc-vimrc或-vimrc中（没有请自行创建）"><a href="#vim相关配置写在-etc-vimrc或-vimrc中（没有请自行创建）" class="headerlink" title="vim相关配置写在/etc/vimrc或~/.vimrc中（没有请自行创建）"></a>vim相关配置写在/etc/vimrc或~/.vimrc中（没有请自行创建）</h4><figure class="highlight vbscript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">set</span> nocompatible <span class="string">"使用vim的键盘模式</span></span><br><span class="line"><span class="string">set tabstop=n "</span>tab宽度</span><br><span class="line"><span class="keyword">set</span> shiftwidth=n <span class="string">"自动缩进时tab空格数</span></span><br><span class="line"><span class="string">set expandtab "</span>tab转空格</span><br><span class="line"><span class="keyword">set</span> noexpandtab <span class="string">"tab转制表符</span></span><br><span class="line"><span class="string">set number "</span>显示行号</span><br><span class="line"><span class="keyword">set</span> showmatch <span class="string">"高亮显示匹配的行号</span></span><br><span class="line"><span class="string">set matchtime=n "</span>匹配括号高亮的时间</span><br><span class="line"><span class="keyword">set</span> cursorline <span class="string">"当前行高亮</span></span><br><span class="line"><span class="string">set history=n "</span>历史记录数</span><br><span class="line"><span class="keyword">set</span> smarttab <span class="string">"在行和段开始处使用制表符</span></span><br><span class="line"><span class="string">set autoindent "</span>自动缩进</span><br><span class="line"><span class="keyword">set</span> hlsearch <span class="string">"搜索字符高亮</span></span><br><span class="line"><span class="string">set syntax=on "</span>语法高亮</span><br><span class="line"><span class="keyword">set</span> encoding=utf<span class="number">-8</span> <span class="string">"编码设置</span></span><br><span class="line"><span class="string">colorscheme &lt;colorscheme&gt; "</span>设置vim配色方案</span><br><span class="line">filetype plugin <span class="keyword">on</span> <span class="string">"允许插件</span></span><br><span class="line"><span class="string">filetype on "</span>侦测文件类型</span><br><span class="line"><span class="keyword">set</span> clipboard=unnamed <span class="string">"共享剪贴板</span></span><br><span class="line"><span class="string">set completeopt=preview,menu "</span>代码补全</span><br><span class="line"><span class="keyword">set</span> completeopt=longest,menu <span class="string">"打开文件类型检测, 加了这句才可以用智能补全</span></span><br><span class="line"><span class="string">"</span>自动补全括号</span><br><span class="line">:inoremap ( ()&lt;ESC&gt;i</span><br><span class="line">:inoremap ) &lt;c-r&gt;=ClosePair(<span class="comment">')')&lt;CR&gt;</span></span><br><span class="line"><span class="string">":inoremap &#123; &#123;&lt;CR&gt;&#125;&lt;ESC&gt;O</span></span><br><span class="line"><span class="string">"</span>:inoremap &#125; &lt;c-r&gt;=ClosePair(<span class="comment">'&#125;')&lt;CR&gt;</span></span><br><span class="line">:inoremap [ []&lt;ESC&gt;i</span><br><span class="line">:inoremap ] &lt;c-r&gt;=ClosePair(<span class="comment">']')&lt;CR&gt;</span></span><br><span class="line">:inoremap <span class="string">" ""&lt;ESC&gt;i</span></span><br><span class="line"><span class="string">:inoremap ' ''&lt;ESC&gt;i</span></span><br><span class="line"><span class="string">function! ClosePair(char)</span></span><br><span class="line"><span class="string">	if getline('.')[col('.') - 1] == a:char</span></span><br><span class="line"><span class="string">		return "</span>\&lt;<span class="built_in">Right</span>&gt;<span class="string">"</span></span><br><span class="line"><span class="string">	else</span></span><br><span class="line"><span class="string">		return a:char</span></span><br><span class="line"><span class="string">	endif</span></span><br><span class="line"><span class="string">endfunction</span></span><br></pre></td></tr></table></figure>

<h4 id="以下记录我的VIM配置"><a href="#以下记录我的VIM配置" class="headerlink" title="以下记录我的VIM配置:"></a>以下记录我的VIM配置:</h4><figure class="highlight vbscript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"set nocompatible</span></span><br><span class="line"><span class="string">set tabstop=4</span></span><br><span class="line"><span class="string">set shiftwidth=4</span></span><br><span class="line"><span class="string">set nu </span></span><br><span class="line"><span class="string">set expandtab</span></span><br><span class="line"><span class="string">set autoindent</span></span><br><span class="line"><span class="string">set showmatch</span></span><br><span class="line"><span class="string">set hlsearch</span></span><br><span class="line"><span class="string">set incsearch</span></span><br><span class="line"><span class="string">set cursorline</span></span><br><span class="line"><span class="string">set encoding=utf-8</span></span><br><span class="line"><span class="string">"</span>filetype off</span><br><span class="line"><span class="keyword">set</span> showcmd</span><br><span class="line"><span class="string">"set rtp+=~/.vim/bundle/plug.vim</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">call plug#begin('~/.vim/plugged')</span></span><br><span class="line"><span class="string">Plug 'neoclide/coc.nvim',&#123;'branch': 'release'&#125;</span></span><br><span class="line"><span class="string">call plug#end()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">set completeopt=longest,menu</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> TextEdit might fail <span class="keyword">if</span> hidden <span class="keyword">is</span> <span class="keyword">not</span> <span class="keyword">set</span>.</span><br><span class="line"><span class="keyword">set</span> hidden</span><br><span class="line"></span><br><span class="line"><span class="string">" Some servers have issues with backup files, see #649.</span></span><br><span class="line"><span class="string">set nobackup</span></span><br><span class="line"><span class="string">set nowritebackup</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Give more <span class="built_in">space</span> <span class="keyword">for</span> displaying messages.</span><br><span class="line"><span class="keyword">set</span> cmdheight=<span class="number">2</span></span><br><span class="line"></span><br><span class="line"><span class="string">" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable</span></span><br><span class="line"><span class="string">"</span> delays <span class="keyword">and</span> poor user experience.</span><br><span class="line"><span class="keyword">set</span> updatetime=<span class="number">300</span></span><br><span class="line"></span><br><span class="line"><span class="string">" Don't pass messages to |ins-completion-menu|.</span></span><br><span class="line"><span class="string">set shortmess+=c</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Always show the signcolumn, otherwise it would shift the text <span class="keyword">each</span> <span class="built_in">time</span></span><br><span class="line"><span class="string">" diagnostics appear/become resolved.</span></span><br><span class="line"><span class="string">set signcolumn=yes</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Use tab <span class="keyword">for</span> trigger completion <span class="keyword">with</span> characters ahead <span class="keyword">and</span> navigate.</span><br><span class="line"><span class="string">" NOTE: Use command ':verbose imap &lt;tab&gt;' to make sure tab is not mapped by</span></span><br><span class="line"><span class="string">"</span> other plugin before putting this into your config.</span><br><span class="line">inoremap &lt;silent&gt;&lt;expr&gt; &lt;TAB&gt;</span><br><span class="line">      \ pumvisible() ? <span class="string">"\&lt;C-n&gt;"</span> :</span><br><span class="line">      \ &lt;SID&gt;check_back_space() ? <span class="string">"\&lt;TAB&gt;"</span> :</span><br><span class="line">      \ coc#refresh()</span><br><span class="line">inoremap &lt;expr&gt;&lt;S-TAB&gt; pumvisible() ? <span class="string">"\&lt;C-p&gt;"</span> : <span class="string">"\&lt;C-h&gt;"</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span>! s:check_back_space() abort</span><br><span class="line">  <span class="keyword">let</span> col = col(<span class="comment">'.') - 1</span></span><br><span class="line">  return !col || getline(<span class="comment">'.')[col - 1]  =~# '\s'</span></span><br><span class="line">endfunction</span><br><span class="line"></span><br><span class="line"><span class="string">" Use &lt;c-space&gt; to trigger completion.</span></span><br><span class="line"><span class="string">inoremap &lt;silent&gt;&lt;expr&gt; &lt;c-space&gt; coc#refresh()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Use &lt;cr&gt; <span class="keyword">to</span> confirm completion, `&lt;C-g&gt;u` means break undo chain at current</span><br><span class="line"><span class="string">" position. Coc only does snippet and additional edit on confirm.</span></span><br><span class="line"><span class="string">"</span> &lt;cr&gt; could be remapped by other vim plugin, try `:verbose imap &lt;CR&gt;`.</span><br><span class="line"><span class="keyword">if</span> exists(<span class="comment">'*complete_info')</span></span><br><span class="line">  inoremap &lt;expr&gt; &lt;cr&gt; complete_info()[<span class="string">"selected"</span>] != <span class="string">"-1"</span> ? <span class="string">"\&lt;C-y&gt;"</span> : <span class="string">"\&lt;C-g&gt;u\&lt;CR&gt;"</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">  inoremap &lt;expr&gt; &lt;cr&gt; pumvisible() ? <span class="string">"\&lt;C-y&gt;"</span> : <span class="string">"\&lt;C-g&gt;u\&lt;CR&gt;"</span></span><br><span class="line">endif</span><br><span class="line"></span><br><span class="line"><span class="string">" Use `[g` and `]g` to navigate diagnostics</span></span><br><span class="line"><span class="string">nmap &lt;silent&gt; [g &lt;Plug&gt;(coc-diagnostic-prev)</span></span><br><span class="line"><span class="string">nmap &lt;silent&gt; ]g &lt;Plug&gt;(coc-diagnostic-next)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> <span class="keyword">GoTo</span> code navigation.</span><br><span class="line">nmap &lt;silent&gt; gd &lt;Plug&gt;(coc-definition)</span><br><span class="line">nmap &lt;silent&gt; gy &lt;Plug&gt;(coc-type-definition)</span><br><span class="line">nmap &lt;silent&gt; gi &lt;Plug&gt;(coc-implementation)</span><br><span class="line">nmap &lt;silent&gt; gr &lt;Plug&gt;(coc-references)</span><br><span class="line"></span><br><span class="line"><span class="string">" Use K to show documentation in preview window.</span></span><br><span class="line"><span class="string">nnoremap &lt;silent&gt; K :call &lt;SID&gt;show_documentation()&lt;CR&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">function! s:show_documentation()</span></span><br><span class="line"><span class="string">  if (index(['vim','help'], &amp;filetype) &gt;= 0)</span></span><br><span class="line"><span class="string">    execute 'h '.expand('&lt;cword&gt;')</span></span><br><span class="line"><span class="string">  else</span></span><br><span class="line"><span class="string">    call CocAction('doHover')</span></span><br><span class="line"><span class="string">  endif</span></span><br><span class="line"><span class="string">endfunction</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Highlight the symbol <span class="keyword">and</span> its references when holding the cursor.</span><br><span class="line">autocmd CursorHold * silent <span class="keyword">call</span> CocActionAsync(<span class="comment">'highlight')</span></span><br><span class="line"></span><br><span class="line"><span class="string">" Symbol renaming.</span></span><br><span class="line"><span class="string">nmap &lt;leader&gt;rn &lt;Plug&gt;(coc-rename)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Formatting selected code.</span><br><span class="line">xmap &lt;leader&gt;f  &lt;Plug&gt;(coc-format-selected)</span><br><span class="line">nmap &lt;leader&gt;f  &lt;Plug&gt;(coc-format-selected)</span><br><span class="line"></span><br><span class="line">augroup mygroup</span><br><span class="line">  autocmd!</span><br><span class="line">  <span class="string">" Setup formatexpr specified filetype(s).</span></span><br><span class="line"><span class="string">  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')</span></span><br><span class="line"><span class="string">  "</span> Update signature help <span class="keyword">on</span> jump placeholder.</span><br><span class="line">  autocmd User CocJumpPlaceholder <span class="keyword">call</span> CocActionAsync(<span class="comment">'showSignatureHelp')</span></span><br><span class="line">augroup <span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="string">" Applying codeAction to the selected region.</span></span><br><span class="line"><span class="string">"</span> Example: `&lt;leader&gt;aap` <span class="keyword">for</span> current paragraph</span><br><span class="line">xmap &lt;leader&gt;a  &lt;Plug&gt;(coc-codeaction-selected)</span><br><span class="line">nmap &lt;leader&gt;a  &lt;Plug&gt;(coc-codeaction-selected)</span><br><span class="line"></span><br><span class="line"><span class="string">" Remap keys for applying codeAction to the current line.</span></span><br><span class="line"><span class="string">nmap &lt;leader&gt;ac  &lt;Plug&gt;(coc-codeaction)</span></span><br><span class="line"><span class="string">"</span> Apply AutoFix <span class="keyword">to</span> problem <span class="keyword">on</span> the current line.</span><br><span class="line">nmap &lt;leader&gt;qf  &lt;Plug&gt;(coc-fix-current)</span><br><span class="line"></span><br><span class="line"><span class="string">" Map function and class text objects</span></span><br><span class="line"><span class="string">"</span> NOTE: Requires <span class="comment">'textDocument.documentSymbol' support from the language server.</span></span><br><span class="line">xmap <span class="keyword">if</span> &lt;Plug&gt;(coc-funcobj-i)</span><br><span class="line">omap <span class="keyword">if</span> &lt;Plug&gt;(coc-funcobj-i)</span><br><span class="line">xmap af &lt;Plug&gt;(coc-funcobj-a)</span><br><span class="line">omap af &lt;Plug&gt;(coc-funcobj-a)</span><br><span class="line">xmap ic &lt;Plug&gt;(coc-classobj-i)</span><br><span class="line">omap ic &lt;Plug&gt;(coc-classobj-i)</span><br><span class="line">xmap ac &lt;Plug&gt;(coc-classobj-a)</span><br><span class="line">omap ac &lt;Plug&gt;(coc-classobj-a)</span><br><span class="line"></span><br><span class="line"><span class="string">" Use CTRL-S for selections ranges.</span></span><br><span class="line"><span class="string">"</span> Requires <span class="comment">'textDocument/selectionRange' support of LS, ex: coc-tsserver</span></span><br><span class="line">nmap &lt;silent&gt; &lt;C-s&gt; &lt;Plug&gt;(coc-range-<span class="keyword">select</span>)</span><br><span class="line">xmap &lt;silent&gt; &lt;C-s&gt; &lt;Plug&gt;(coc-range-<span class="keyword">select</span>)</span><br><span class="line"></span><br><span class="line"><span class="string">" Add `:Format` command to format current buffer.</span></span><br><span class="line"><span class="string">command! -nargs=0 Format :call CocAction('format')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Add `:Fold` command <span class="keyword">to</span> fold current buffer.</span><br><span class="line">command! -nargs=? Fold :<span class="keyword">call</span>     CocAction(<span class="comment">'fold', &lt;f-args&gt;)</span></span><br><span class="line"></span><br><span class="line"><span class="string">" Add `:OR` command for organize imports of the current buffer.</span></span><br><span class="line"><span class="string">command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"</span> Add (Neo)Vim<span class="comment">'s native statusline support.</span></span><br><span class="line"><span class="string">" NOTE: Please see `:h coc-status` for integrations with external plugins that</span></span><br><span class="line"><span class="string">"</span> provide custom statusline: lightline.vim, vim-airline.</span><br><span class="line"><span class="keyword">set</span> statusline^=%&#123;coc#status()&#125;%&#123;<span class="keyword">get</span>(b:,<span class="comment">'coc_current_function','')&#125;</span></span><br><span class="line"></span><br><span class="line"><span class="string">" Mappings using CoCList:</span></span><br><span class="line"><span class="string">"</span> Show all diagnostics.</span><br><span class="line">nnoremap &lt;silent&gt; &lt;<span class="built_in">space</span>&gt;a  :&lt;C-u&gt;CocList diagnostics&lt;cr&gt;</span><br><span class="line"><span class="string">" Manage extensions.</span></span><br><span class="line"><span class="string">nnoremap &lt;silent&gt; &lt;space&gt;e  :&lt;C-u&gt;CocList extensions&lt;cr&gt;</span></span><br><span class="line"><span class="string">"</span> Show commands.</span><br><span class="line">nnoremap &lt;silent&gt; &lt;<span class="built_in">space</span>&gt;c  :&lt;C-u&gt;CocList commands&lt;cr&gt;</span><br><span class="line"><span class="string">" Find symbol of current document.</span></span><br><span class="line"><span class="string">nnoremap &lt;silent&gt; &lt;space&gt;o  :&lt;C-u&gt;CocList outline&lt;cr&gt;</span></span><br><span class="line"><span class="string">"</span> Search workspace symbols.</span><br><span class="line">nnoremap &lt;silent&gt; &lt;<span class="built_in">space</span>&gt;s  :&lt;C-u&gt;CocList -I symbols&lt;cr&gt;</span><br><span class="line"><span class="string">" Do default action for next item.</span></span><br><span class="line"><span class="string">nnoremap &lt;silent&gt; &lt;space&gt;j  :&lt;C-u&gt;CocNext&lt;CR&gt;</span></span><br><span class="line"><span class="string">"</span> <span class="keyword">Do</span> <span class="keyword">default</span> action <span class="keyword">for</span> previous item.</span><br><span class="line">nnoremap &lt;silent&gt; &lt;<span class="built_in">space</span>&gt;k  :&lt;C-u&gt;CocPrev&lt;CR&gt;</span><br><span class="line"><span class="string">" Resume latest coc list.</span></span><br><span class="line"><span class="string">nnoremap &lt;silent&gt; &lt;space&gt;p  :&lt;C-u&gt;CocListResume&lt;CR&gt;</span></span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/vim-config/" data-id="ckpb8zvlh003fdsvl2pf0hxrg" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vim/" rel="tag">vim</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-vim-operator" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/vim-operator/" class="article-date">
  <time datetime="2020-03-15T14:44:48.000Z" itemprop="datePublished">2020-03-15</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/vim-operator/">vim相关操作</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="以下列出VIM的相关的基本操作。"><a href="#以下列出VIM的相关的基本操作。" class="headerlink" title="以下列出VIM的相关的基本操作。"></a>以下列出VIM的相关的基本操作。</h2><ul>
<li><p>光标上下左右移动：k(up) j(down) h(left) l(right)</p>
<ol>
<li>也可通过方向键来移动</li>
</ol>
</li>
<li><p>退出==’:q’ ，保存后退出==’:wq’，不保存退出==’:q!’</p>
</li>
<li><p>复制==’y’，剪切==’d’，粘贴==’p’</p>
<ol>
<li>多行复制==’nyy/yny’</li>
<li>剪切、粘贴同复制</li>
</ol>
</li>
<li><p>可视化模式==’v’</p>
<ol>
<li>可对文本进行鼠标操作</li>
</ol>
</li>
<li><p>进入编辑模式</p>
<ol>
<li>向后插入==’a’</li>
<li>向前插入==’i’</li>
<li>删除并插入==’s’</li>
<li>回车后插入==’o’</li>
</ol>
</li>
<li><p>代码提示、补充</p>
<ol>
<li>向前补充==’ctrl+n’</li>
<li>向后补充==’ctrl+p’</li>
</ol>
</li>
<li><p>分屏==’ctrl+w’</p>
<ol>
<li>上下分屏==’s’</li>
<li>上下分屏打开文件==’:sp filepath’(不需要ctrl+w)</li>
<li>在当前屏幕上方新建空文档==’n’</li>
<li>左右分屏==’v’</li>
<li>左右分屏打开文件==’:vsp filepath’(不需要ctrl+w)</li>
<li>跳到下一个分屏==’w’</li>
<li>退出当前分屏==’c’/‘q’</li>
<li>调整分屏宽高==’+’/‘&gt;’/‘&lt;’/‘-‘/‘=’</li>
<li>分屏交换==’H’(left) ‘J’(down) ‘K’(up) ‘L’(right)</li>
</ol>
</li>
<li><p>快速移动光标至行首==’home’，行尾==’end’，文本头==’gg’，文本尾==’G’</p>
<ol>
<li>跳至对应的行==’xxG’(xx为第几行)</li>
</ol>
</li>
<li><p>整理代码==’=’</p>
</li>
<li><p>全部代码格式化==’gg=G’</p>
</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/vim-operator/" data-id="ckpb8zvl20035dsvl65l859xl" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vim/" rel="tag">vim</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    
    <a class="extend prev" rel="prev" href="/page/10/">&amp;laquo; 上一页</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/9/">9</a><a class="page-number" href="/page/10/">10</a><span class="page-number current">11</span><a class="page-number" href="/page/12/">12</a><a class="page-number" href="/page/13/">13</a><a class="extend next" rel="next" href="/page/12/">下一页 &amp;raquo;</a>
  </nav>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/" rel="tag">android</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/data-structure/" rel="tag">data structure</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/" rel="tag">docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/go/" rel="tag">go</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/" rel="tag">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/" rel="tag">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/" rel="tag">javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/json/" rel="tag">json</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/" rel="tag">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/maven/" rel="tag">maven</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mybatis/" rel="tag">mybatis</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mysql/" rel="tag">mysql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/network/" rel="tag">network</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/" rel="tag">nodejs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/searching/" rel="tag">searching</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sorting/" rel="tag">sorting</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sublime-text/" rel="tag">sublime text</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/termux/" rel="tag">termux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/theia/" rel="tag">theia</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/typora/" rel="tag">typora</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vala/" rel="tag">vala</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/" rel="tag">vim</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vue/" rel="tag">vue</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zig/" rel="tag">zig</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zookeeper/" rel="tag">zookeeper</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/data-structure/" style="font-size: 10px;">data structure</a> <a href="/tags/docker/" style="font-size: 10px;">docker</a> <a href="/tags/git/" style="font-size: 15px;">git</a> <a href="/tags/go/" style="font-size: 10px;">go</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/java/" style="font-size: 18.33px;">java</a> <a href="/tags/javascript/" style="font-size: 11.67px;">javascript</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/linux/" style="font-size: 20px;">linux</a> <a href="/tags/maven/" style="font-size: 10px;">maven</a> <a href="/tags/mybatis/" style="font-size: 10px;">mybatis</a> <a href="/tags/mysql/" style="font-size: 11.67px;">mysql</a> <a href="/tags/network/" style="font-size: 11.67px;">network</a> <a href="/tags/nginx/" style="font-size: 10px;">nginx</a> <a href="/tags/nodejs/" style="font-size: 13.33px;">nodejs</a> <a href="/tags/searching/" style="font-size: 10px;">searching</a> <a href="/tags/sorting/" style="font-size: 16.67px;">sorting</a> <a href="/tags/sublime-text/" style="font-size: 10px;">sublime text</a> <a href="/tags/termux/" style="font-size: 10px;">termux</a> <a href="/tags/theia/" style="font-size: 10px;">theia</a> <a href="/tags/typora/" style="font-size: 10px;">typora</a> <a href="/tags/vala/" style="font-size: 10px;">vala</a> <a href="/tags/vim/" style="font-size: 15px;">vim</a> <a href="/tags/vue/" style="font-size: 11.67px;">vue</a> <a href="/tags/zig/" style="font-size: 10px;">zig</a> <a href="/tags/zookeeper/" style="font-size: 10px;">zookeeper</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/05/">五月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/04/">四月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/03/">三月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/01/">一月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/11/">十一月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/10/">十月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/09/">九月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/08/">八月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">七月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/06/">六月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/05/">五月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/03/">三月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/02/">二月 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/java-hashmap/">java.util.HashMap</a>
          </li>
        
          <li>
            <a href="/jvm/">JVM</a>
          </li>
        
          <li>
            <a href="/java-locks/">Java锁</a>
          </li>
        
          <li>
            <a href="/java-references/">Java引用</a>
          </li>
        
          <li>
            <a href="/gitea/">Gitea</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2021 Alanisia<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>